<html>
<head><meta charset="utf-8"><title>feature: move mod to new file · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/feature.3A.20move.20mod.20to.20new.20file.html">feature: move mod to new file</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196998044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/feature%3A%20move%20mod%20to%20new%20file/near/196998044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cole Lawrence <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/feature.3A.20move.20mod.20to.20new.20file.html#196998044">(May 09 2020 at 15:59)</a>:</h4>
<p>Hi, I have an idea for a feature that might already be tracked, but I'm not finding it anywhere.<br>
When I write <code>mod nonexistent_module;</code> I get a code action for creating the module, which will create a new file.<br>
I'm interested in writing a module with the <code>mod nonexistent_module { ... }</code> syntax, and then once it's in a sufficiently complex state, I can move the contents of the <code>mod</code> "..." into a new file.<br>
Would that feature be hard to add? I think it would really help my team understand Rust's module system incrementally, so we can write our code in modules by default (using <code>mod name { ... }</code>) and move them into their own files "safely" as they become sufficiently complex. It would also make the process of refactoring large amounts of interdependent code a little easier by allowing you to do all the module organization and dependency resolving in one file, and incrementally break the file up into modules.</p>



<a name="197000703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/feature%3A%20move%20mod%20to%20new%20file/near/197000703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/feature.3A.20move.20mod.20to.20new.20file.html#197000703">(May 09 2020 at 16:52)</a>:</h4>
<p>Yes, I've been waiting for this feature for a long time, but never got to actually implementing it.</p>



<a name="197000712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/feature%3A%20move%20mod%20to%20new%20file/near/197000712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/feature.3A.20move.20mod.20to.20new.20file.html#197000712">(May 09 2020 at 16:52)</a>:</h4>
<p>Shouldn't be hard to add (it should be an <code>assist</code>), though, at the moment, we do some refactorings in the area, so some slight merge conflicts are expected</p>



<a name="197045848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/feature%3A%20move%20mod%20to%20new%20file/near/197045848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/feature.3A.20move.20mod.20to.20new.20file.html#197045848">(May 10 2020 at 10:03)</a>:</h4>
<p>Hooray for more helpful assists!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>